package net.zjitc.controller.client;

import net.zjitc.pojo.User;
import net.zjitc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author admin
 * @Date 2019/5/22 10:34
 */
@Controller
public class RegisterController {
    @Autowired
    UserService userService;

    @RequestMapping(value = "/registerUI")
    public String loginUI(){
        return "/client/singup";
    }

    @RequestMapping(value = "/register")
    public String login(User user, Model model){
        User tel = userService.search_tel(user.getTelephone());
        if (tel != null)
        {
            model.addAttribute("news","手机号已被注册，请直接登录");
            return "/client/login";
        }
        userService.user_register(user);
//        return "redirect:/loginUI";
        return "/client/login";
    }
}
